﻿using System;
using System.Collections.Generic;
using System.Web;

namespace WxPayAPI
{
    /**
    * 	配置账号信息
    */
    public class WxPayConfig
    {
        private static WxPayConfig _Instance = null;
        public static WxPayConfig Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new WxPayConfig();
                }
                return _Instance;
            }
        }
        //=======【基本信息设置】=====================================
        /* 微信公众号信息配置
        * APPID：绑定支付的APPID（必须配置）
        * MCHID：商户号（必须配置）
        * KEY：商户支付密钥，参考开户邮件设置（必须配置）
        * APPSECRET：公众帐号secert（仅JSAPI支付的时候需要配置）
        */
        public string APPID = "";
        public string APPSECRET = "";
        public string MCHID = "";
        public string KEY = "";

        //=======【证书路径设置】===================================== 
        /* 证书路径,注意应该填写绝对路径（仅退款、撤销订单时需要）
        */
        public string SSLCERT_PATH = "";
        public string SSLCERT_PASSWORD = "";



        //=======【支付结果通知url】===================================== 
        /* 支付结果通知回调url，用于商户接收支付结果
        */
        public string NOTIFY_URL = "http://xianyongyong.com/Crowdfunding/PayResult.aspx";

        //=======【商户系统后台机器IP】===================================== 
        /* 此参数可手动配置也可在程序中自动获取
        */
        public string IP = "117.79.84.212";


        //=======【代理服务器设置】===================================
        /* 默认IP和端口号分别为0.0.0.0和0，此时不开启代理（如有需要才设置）
        */
        public string PROXY_URL = "";

        //=======【上报信息配置】===================================
        /* 测速上报等级，0.关闭上报; 1.仅错误时上报; 2.全量上报
        */
        public int REPORT_LEVENL = 0;

        //=======【日志级别】===================================
        /* 日志等级，0.不输出日志；1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息
        */
        public int LOG_LEVENL = 1;

        public WxPayConfig()
        {
            APPID = System.Configuration.ConfigurationManager.AppSettings["AppID"];
            APPSECRET = System.Configuration.ConfigurationManager.AppSettings["AppSecret"];
            MCHID = System.Configuration.ConfigurationManager.AppSettings["MCHID"];
            KEY = System.Configuration.ConfigurationManager.AppSettings["KEY"];
            SSLCERT_PATH = System.Configuration.ConfigurationManager.AppSettings["SSLCERT_PATH"];
            SSLCERT_PASSWORD = System.Configuration.ConfigurationManager.AppSettings["SSLCERT_PASSWORD"];
            NOTIFY_URL = System.Configuration.ConfigurationManager.AppSettings["NOTIFY_URL"];
            IP = System.Configuration.ConfigurationManager.AppSettings["IP"];
            PROXY_URL = System.Configuration.ConfigurationManager.AppSettings["PROXY_URL"];
            REPORT_LEVENL = int.Parse(System.Configuration.ConfigurationManager.AppSettings["REPORT_LEVENL"]);
            LOG_LEVENL = int.Parse(System.Configuration.ConfigurationManager.AppSettings["LOG_LEVENL"]);
        }
    }
}